<?php
/**
 * 杂项方法
 * Created by PhpStorm.
 * User: dell
 * Date: 2018/7/16
 * Time: 9:31
 */
namespace app\wchat\controller;
use think\Request;

class Misc extends Common
{
    /**
     * 工具单
     * @param Request $request
     */
    public function lendVer(){
        return $this->fetch('lend');
    }

    /**
     * 工具出借确认
     * @param Request $request
     */
    public function toolsConf(Request $request){
        $tid = $request->param('id');

        $info = db('tools_lend')->where('id',$tid)->find();

        if($info['state_id']==43){
            return ['code'=>0,'msg'=>'该出借单已作废'];
        }

        if($info['is_var'] == 1){
            return ['code'=>0,'msg'=>'该出借单已确认'];
        }

        $row = db('tools_lend')->where('id',$tid)->update(['is_ver'=>1]);

        if($row)
            return ['code'=>1,'msg'=>'已确认成功'];
        return ['code'=>0,'msg'=>'确认失败'];
    }

}